import 'package:get_it/get_it.dart';
import 'package:mobile_app.core/injection_container.dart' as core_di;
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/helpers/apply_custom_collection_folder_all_collection_deletion/helper.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/helpers/find_custom_collection_folder/helper.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/helpers/get_all_collection_lexical_item_ids/helper.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/helpers/get_collection_folder_collections_by_ids/helper.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/helpers/is_collection_creation_permitted/helper.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/cancel_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/cancel_collection_reordering/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/complete_collection_creation/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/complete_collection_folder_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/complete_collection_folder_renaming/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/complete_collection_reordering/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/complete_selected_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/deselect_all_collections_during_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/get_initial_data/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_creation_learning_content_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_creation_premium_access_status_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_deletion_learning_content_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_deletion_premium_access_status_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_folder_renaming_learning_content_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_folder_renaming_premium_access_status_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_reordering_learning_content_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_collection_reordering_premium_access_status_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_default_state_learning_content_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/handle_default_state_premium_access_status_outer_update/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/select_all_collections_during_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/start_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/start_collection_folder_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/start_selected_collection_deletion/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/swap_collections/use_case.dart';
import 'package:mobile_app.home.collections/single_custom_collection_folder_page/domain/use_cases/toggle_collection_deletion_selection/use_case.dart';
import 'package:mobile_app.home.collections.core/injection_container.dart' as collection_core_di;
import 'package:mobile_app.home.core/injection_container.dart' as home_core_di;

final sl = GetIt.asNewInstance();

Future<void> init() async {
  // domain helpers

  sl.registerLazySingleton<ApplyCustomCollectionFolderAllCollectionDeletion>(() {
    return const ApplyCustomCollectionFolderAllCollectionDeletionImpl();
  });

  sl.registerLazySingleton<FindCustomCollectionFolder>(() {
    return const FindCustomCollectionFolderImpl();
  });

  sl.registerLazySingleton<GetAllCollectionLexicalItemIds>(() {
    return const GetAllCollectionLexicalItemIdsImpl();
  });

  sl.registerLazySingleton<GetCollectionFolderCollectionsByIds>(() {
    return const GetCollectionFolderCollectionsByIdsImpl();
  });

  sl.registerLazySingleton<IsCollectionCreationPermitted>(() {
    return const IsCollectionCreationPermittedImpl();
  });

  // use cases

  sl.registerLazySingleton<CancelCollectionDeletion>(() {
    return CancelCollectionDeletionImpl(
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<CancelCollectionReordering>(() {
    return CancelCollectionReorderingImpl(
      findCustomCollectionFolder: sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<CompleteCollectionCreation>(() {
    return CompleteCollectionCreationImpl(
      applyCollectionListItemUpdate: home_core_di.sl(),
      learningContentRepository: core_di.sl(),
      getPermittedCollectionListItemIds: home_core_di.sl(),
      createCustomCollection: collection_core_di.sl(),
      validateCustomCollectionTitle: collection_core_di.sl(),
    );
  });

  sl.registerLazySingleton<CompleteCollectionFolderDeletion>(() {
    return CompleteCollectionFolderDeletionImpl(
      learningContentRepository: core_di.sl(),
      filterCustomLexicalItemIds: collection_core_di.sl(),
      filterCustomCollectionExclusiveLexicalItemIds: collection_core_di.sl(),
      applyAllCollectionListItemNonexistentLexicalItemRemoval: home_core_di.sl(),
      applyCustomCollectionListItemDeletion: collection_core_di.sl(),
      getAllCollectionLexicalItemIds: sl(),
    );
  });

  sl.registerLazySingleton<CompleteCollectionFolderRenaming>(() {
    return CompleteCollectionFolderRenamingImpl(
      learningContentRepository: core_di.sl(),
      applyCollectionListItemUpdate: home_core_di.sl(),
      validateCustomCollectionFolderTitle: collection_core_di.sl(),
    );
  });

  sl.registerLazySingleton<CompleteCollectionReordering>(() {
    return CompleteCollectionReorderingImpl(
      learningContentRepository: core_di.sl(),
      applyCollectionListItemUpdate: home_core_di.sl(),
      isCollectionCreationPermitted: sl(),
      findCustomCollectionFolder: sl(),
    );
  });

  sl.registerLazySingleton<CompleteSelectedCollectionDeletion>(() {
    return CompleteSelectedCollectionDeletionImpl(
      learningContentRepository: core_di.sl(),
      applyCollectionListItemUpdate: home_core_di.sl(),
      isCollectionCreationPermitted: sl(),
      getAllCollectionLexicalItemIds: sl(),
      applyAllCollectionListItemNonexistentLexicalItemRemoval: home_core_di.sl(),
      filterCustomCollectionExclusiveLexicalItemIds: collection_core_di.sl(),
      filterCustomLexicalItemIds: collection_core_di.sl(),
      getPermittedCollectionListItemIds: home_core_di.sl(),
      applyCustomCollectionFolderAllCollectionDeletion: sl(),
      getCollectionFolderCollectionsByIds: sl(),
    );
  });

  sl.registerLazySingleton<DeselectAllCollectionsDuringCollectionDeletion>(() {
    return const DeselectAllCollectionsDuringCollectionDeletionImpl();
  });

  sl.registerLazySingleton<GetInitialData>(() {
    return GetInitialDataImpl(
      isCollectionCreationPermitted: sl(),
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionCreationLearningContentOuterUpdate>(() {
    return HandleCollectionCreationLearningContentOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionCreationPremiumAccessStatusOuterUpdate>(() {
    return HandleCollectionCreationPremiumAccessStatusOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionDeletionLearningContentOuterUpdate>(() {
    return HandleCollectionDeletionLearningContentOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionDeletionPremiumAccessStatusOuterUpdate>(() {
    return HandleCollectionDeletionPremiumAccessStatusOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionFolderRenamingLearningContentOuterUpdate>(() {
    return HandleCollectionFolderRenamingLearningContentOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionFolderRenamingPremiumAccessStatusOuterUpdate>(() {
    return HandleCollectionFolderRenamingPremiumAccessStatusOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionReorderingLearningContentOuterUpdate>(() {
    return HandleCollectionReorderingLearningContentOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<HandleCollectionReorderingPremiumAccessStatusOuterUpdate>(() {
    return HandleCollectionReorderingPremiumAccessStatusOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
    );
  });

  sl.registerLazySingleton<HandleDefaultStateLearningContentOuterUpdate>(() {
    return HandleDefaultStateLearningContentOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      findCustomCollectionFolder: sl(),
    );
  });

  sl.registerLazySingleton<HandleDefaultStatePremiumAccessStatusOuterUpdate>(() {
    return HandleDefaultStatePremiumAccessStatusOuterUpdateImpl(
      getPermittedCollectionListItemIds: home_core_di.sl(),
      isCollectionCreationPermitted: sl(),
    );
  });

  sl.registerLazySingleton<SelectAllCollectionsDuringCollectionDeletion>(() {
    return const SelectAllCollectionsDuringCollectionDeletionImpl();
  });

  sl.registerLazySingleton<StartCollectionDeletion>(() {
    return const StartCollectionDeletionImpl();
  });

  sl.registerLazySingleton<StartCollectionFolderDeletion>(() {
    return StartCollectionFolderDeletionImpl(
      filterCustomLexicalItemIds: collection_core_di.sl(),
      getAllCollectionLexicalItemIds: sl(),
    );
  });

  sl.registerLazySingleton<StartSelectedCollectionDeletion>(() {
    return StartSelectedCollectionDeletionImpl(
      filterCustomLexicalItemIds: collection_core_di.sl(),
      getAllCollectionLexicalItemIds: sl(),
      getCollectionFolderCollectionsByIds: sl(),
    );
  });

  sl.registerLazySingleton<SwapCollections>(() {
    return const SwapCollectionsImpl();
  });

  sl.registerLazySingleton<ToggleCollectionDeletionSelection>(() {
    return const ToggleCollectionDeletionSelectionImpl();
  });
}
